package com.tengju.bff.infrastructure.export.repo;

import com.tengju.bff.infrastructure.export.convert.TableVoConvert;
import com.tengju.bff.interfaces.manage.crm.activity.facade.ActivityTargetAnalysisFacade;
import com.tengju.bff.interfaces.manage.crm.activity.form.ActivityTeamQuery;
import com.tengju.bff.interfaces.shared.ColumnVO;
import com.tengju.bff.interfaces.shared.TableVO;
import com.tengju.export.domain.record.ExportDataSourceRepository;
import com.tengju.export.domain.record.Query;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author: 大木
 * @date: 2022/1/13 10:09 上午
 */
@RequiredArgsConstructor(onConstructor_ ={@Autowired})
@Service("secTargetReachExportDataSourceRepository")
public class SecTargetReachExportDataSourceRepository implements ExportDataSourceRepository {

    private final ActivityTargetAnalysisFacade activityTargetAnalysisFacade;

    @Override
    public Object batchFindDataSource(Query query) {
        ActivityTeamQuery pageQuery = (ActivityTeamQuery)query;
        pageQuery.setPageSize(100000);
        pageQuery.setPageIndex(1);
        TableVO tableVO = activityTargetAnalysisFacade.secTargetReachTable(pageQuery);
        tableVO.addColumn(null, ColumnVO.of("userNickname", "昵称", false));
        tableVO.addColumn(null, ColumnVO.of("userStarLevel", "用户等级", false));
        tableVO.addColumn(null, ColumnVO.of("userIdCode", "IdCode", false));
        tableVO.removeColumn("userShowName");
        tableVO.removeColumn("supInfo");
        return TableVoConvert.convert(tableVO);
    }
}